package com.mayikt.advice;

import com.alibaba.fastjson.JSONObject;
import com.mayikt.base.BaseApiService;
import com.mayikt.base.BaseResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Classname GlobalControllerAdvice
 * @Description SpringBoot SpringCloud 构建微服务电商平台。
 * @Created by CHEN JIN LONG
 * @Date 2019/1/24 22:36
 * @Version 1.0
 */
@ControllerAdvice
@Slf4j
public class GlobalExceptionAdvice extends BaseApiService<JSONObject> {

    @ResponseBody
    public BaseResponse<JSONObject> exceptionHandler(Exception e) {
        log.info("###全局捕获异常###，error：{}", e);
        return setResultError("系统错误！");
    }
}
